//package ServletDemo;
///**
// * 登录功能
// * 获取username和passwd
// * 将username和passwd封装
// * 调用UserDao的login方法，获取返回的User对象
// * 判断username和passwd的正确行，并根据条件跳转不同的页面
// */
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
//public class DealServlet extends HttpServlet {
//    @Override
//    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        doPost(req, resp);
//    }
//    @Override
//    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//
//        //设置服务器端以GB2312编码进行输出
//        resp.setCharacterEncoding("UTF-8");
//        //设置浏览器以UTF-8编码进行接收,解决中文乱码问题
//        resp.setContentType("text/html;charset=UTF-8");
//        PrintWriter out=resp.getWriter();
//        String userName = req.getParameter("username");//获取登录名
//        String passWd = req.getParameter("passwd");//获取密码
//        System.out.println("登录名" + userName);
//        System.out.println("密码"+ passWd);
//        if(userName.equals("") || passWd.equals("")){//判断密码和用户名是否为null
//            resp.sendRedirect("http://localhost:8080/javaWeb_war_exploded/ServletDemo/PassWdError");//跳转页面
////            http://localhost:8080/javaWeb_war_exploded/ServletDemo/DateServlet
////            http://localhost:8080/javaWeb_war_exploded/ServletDemo/PassWdError
//
//            System.out.println("执行到没输入密码");//
//
//        } else{
//            if(userName.equals(passWd)){//判断用户名是否等于密码
////                resp.sendRedirect("http://localhost:8080/javaWeb_war_exploded/ServletDemo/cookiesDemo");//跳转页面
//                resp.sendRedirect("http://localhost:8080/javaWeb_war_exploded/successCookies.jsp");//跳转到计数页面
//                System.out.println("执行到密码等于用户名");
////                if(req.getParameter("keep")!=null){
////                    Cookie usernamecookie = new Cookie("username",userName);
////                    usernamecookie.setMaxAge(14*24*60*60);
////                    resp.addCookie(usernamecookie);
////                }else{
////                }
//            }
//            else{
//                resp.sendRedirect("http://localhost:8080/javaWeb_war_exploded/ServletDemo/PassWdError");//跳转页面
//                System.out.println("执行到密码错误");
//            }
//        }
//    }
//}